<template>
  <div>
    <div class="huize_information">
      <div class="centre">
        <div class="information_buttom">
          <h3>高考动态</h3>
          <div class="top_header">
            <ul>
              <li
                v-for="(tiem, index) in tabsParam"
                :key="index"
                @click="addNewAdvisory(index)"
              >
                {{ tiem }}
              </li>
            </ul>
          </div>
        </div>
      </div>
      <div class="information_content">
    
        <ul>
          <router-link
            :to="{
              name: '/AdvisoryDetails/advisory',
              params: {
                id: list.id
              }
            }"
            tag="li"
            v-for="(list, index) in conetent.list"
            :key="list.id"
          >
            <div class="content_left">
              <h4>{{ list.title }}</h4>
              <div class="content" v-html="list.content"></div>
              <div class="tyle_item">
                <div class="tyle">
                  #{{
                    Type == "0"
                      ? "教育部"
                      : Type == "1"
                      ? "本省政策"
                      : Type == "2"
                      ? "最新动态"
                      : " "
                  }}
                </div>
                <div class="item">{{ list.editTime }}</div>
              </div>
            </div>
            <div class="content_right">
              <img :src="list.picOne" alt />
            </div>
          </router-link>
        </ul>

        <h2 @click="addMore" v-if="totalCount + 1 > pageSize">查看更多</h2>
        <h2 v-else>没有更多了</h2>
      </div>
    </div>
  </div>
</template>
<script>
import Content from "./content";
export default {
  name: "Information",
  components: {
    Content
  },
  data() {
    return {
      tabsParam: ["教育部", "本省政策", "最新动态"],
      Type: 0,
      conetent: "",
      pageSize: 3,
      totalCount: ""
    };
  },
  methods: {
    addNewAdvisory(ID) {
      console.log(ID);
      this.Type = ID;
      this.addConetent();
    },
    addConetent() {
      this.$ajax({
        method: "post",
        url: "/api/policy/list",
        data: {
          pageNow: 1,
          pageSize: this.pageSize,
          type: this.Type
        },

        success: res => {
          if (res.data.code == 0) {
            this.conetent = res.data.data;
            this.totalCount = res.data.data.totalCount;
          } else {
          }
        }
      });
    },
    addMore() {
      this.pageSize += 10;
      this.addConetent();
    }
  },
  beforeCreate() {
    this.$nextTick(() => {
      this.addConetent();
    });
  }
};
</script>

<style lang="scss" scoped>
.information_top {
  padding: 46px 0;
  display: flex;
  justify-content: space-between;
  div {
    width: 580px;
    height: 192px;
    background: #f6f6f6;
    border-radius: 6px;
  }
}
.information_buttom {
  h3 {
    margin-bottom: 36px;
  }
  .top_header {
    margin-bottom: 26px;
    ul {
      display: flex;
      li {
        cursor: pointer;
        margin-right: 62px;
        color: #959595;
      }
    }
  }
}
.information_content {
  h2 {
    text-align: center;
    line-height: 64px;
    color: #959595;
    font-size: 18px;
  }
  ul {
    li {
      background: #f0f0f0;
      display: flex;
      justify-content: space-between;
      padding: 28px 72px;
      margin-bottom: 24px;
      border-radius: 3px;
      .content_left {
        margin-top: 12px;
        h4 {
          color: #414141;
          line-height: 42px;
          font-size: 20px;
        }
        .content {
          width: 830px;
          color: #757575;
          font-size: 14px;
          line-height: 20px;
          display: -webkit-box;
          -webkit-box-orient: vertical;
          -webkit-line-clamp: 3;
          overflow: hidden;
        }
        .tyle_item {
          display: flex;
          justify-content: space-between;
          width: 318px;
          padding: 40px 0;
          font-size: 12px;
          color: #8a8a8a;
        }
      }
      .content_right {
        img {
          width: 172px;
          height: 172px;
          border-radius: 6px;
        }
      }
    }
  }
}
</style>
